package br.com.controller;

import java.sql.Connection;
import java.util.List;

import br.com.bean.CorBean;
import br.com.bean.HorarioBean;
import br.com.dao.CorDao;
import br.com.dao.HorarioDao;



public class HorarioController {

	public static void inserir(Connection conn, String esc, String cpf, int mat, int fls, 
			String cont, String ent1, String sad1, String ent2, 
			String sad2, String obs) throws Exception{
		
		HorarioBean hrs = new HorarioBean();
		hrs.setId_escola(esc);
		hrs.getId_cpf().setCpf(cpf);
		hrs.setMatricula(mat);
		hrs.setFolha(fls);
		hrs.setContrato(cont);
		hrs.setEntrada1(ent1);
		hrs.setSaida1(sad1);
		hrs.setEntrada2(ent2);
		hrs.setSaida2(sad2);
		hrs.setObservacao(obs);
		
	    HorarioDao dao = new HorarioDao();
		dao.inserir(conn,hrs);
	}
		
	public static void excluir(Connection conn, int id) throws Exception{
		
		HorarioBean hrs = new HorarioBean();
		hrs.setId(id);
		
		HorarioDao dao = new HorarioDao();
		dao.excluir(conn,hrs);
	}
	
	public static void update(Connection conn, String descricao, int id, String esc, 
			String cpf, int mat, int fls, String cont, String ent1, String sad1, String ent2, 
			String sad2, String obs) throws Exception{
		
		HorarioBean hrs = new HorarioBean();
		hrs.setId(id);
		hrs.setId_escola(esc);
		hrs.getId_cpf().setCpf(cpf);
		hrs.setMatricula(mat);
		hrs.setFolha(fls);
		hrs.setContrato(cont);
		hrs.setEntrada1(ent1);
		hrs.setSaida1(sad1);
		hrs.setEntrada2(ent2);
		hrs.setSaida2(sad2);
		hrs.setObservacao(obs);
	       
		HorarioDao dao = new HorarioDao();
		dao.alterar(conn,hrs);
}
	// Horario geral
	public static List<HorarioBean> ListHrsGeral(Connection conn) throws Exception{
		
		HorarioDao dao = new HorarioDao();
		List<HorarioBean> naList = dao.getListaHrs(conn);
		
		return naList;
	}
	// Horario especifico
		public static List<HorarioBean> ListHrsEsp(Connection conn, String cpf) throws Exception{
			HorarioBean hrs = new HorarioBean();
			hrs.getId_cpf().setCpf(cpf);
			
			HorarioDao dao = new HorarioDao();
			List<HorarioBean> naList = dao.getListaHrs(conn, hrs);
			
			return naList;
		}		
}